<?php 
    header("Content-Type: text/html;charset=utf-8"); 
	include("../function/_nosql.php");
	include("../function/function.php");
	require_once "../weipay/WxPay.JsApiPay.php";
	$tools = new JsApiPay();
    $openId = $tools->GetOpenid();
    if($openId != ''){
        $piao = getNewsNums("kboy_weiopenid","wei_openid='$openId'");
	    if($piao == 0){
	        $mysql = new sqlstr("kboy_weiopenid"); 
		    $mysql -> set("wei_openid",$openId);
		    $news_sql = $mysql -> insertSql();
		    $news_res = mysql_query($news_sql);
		    $openid = mysql_insert_id();
		    if($news_res){
		        echo re("./toupiao.php?open=".$openid."");
		    }
	    }else{
	        $openid = getClassName("kboy_weiopenid","id","wei_openid='$openId'");
	        echo re("./toupiao.php?open=".$openid.""); 
	    }
    }else{
        error("请从微信订阅号重新进入");
    }
?>